
# Instantiate
	library(foreign)
  rueda = read.csv("Duplication dataset.csv")
	attach(rueda)

# rename minwage
	minwag = rueda$min

library("lmtest")
library("plm")


## compare min wage marginal effects for all and for minwage countries only

dvmin2 = plm(minwag~govpart+hkcorp+govpart:hkcorp+open+finop+dccggx+unemp+gdpgr+deca70+deca80+deca85+deca90,data=rueda,model="within")
dvmin3 = coeftest(dvmin2, vcov=function(x) vcovBK(x, diagonal=T,cluster=c("time")))
dvmin4 = plm(minwag~govpart+hkcorp+govpart:hkcorp+open+finop+dccggx+unemp+gdpgr+deca70+deca80+deca85+deca90,data=rueda,subset=minwag>0,model="within")
dvmin5 = coeftest(dvmin4, vcov=function(x) vcovBK(x, diagonal=T,cluster=c("time")))

par(mfrow=c(1,2))
## govpart--> minwag
plot(na.omit(hkcorp),dvmin2$coeff["govpart"] + na.omit(hkcorp)*dvmin2$coeff["govpart:hkcorp"],"l",lwd=3,ylab="Left Government",xlab="Level of Corporatism",main="Minimum Wage, All Countries",ylim=c(-.0007,.001))
# Rueda
lines(lowess(na.omit(hkcorp), dvmin2$coeff["govpart"] + na.omit(hkcorp)*dvmin2$coeff["govpart:hkcorp"] + 1.96*sqrt( dvmin3["govpart",2]^2 +(na.omit(hkcorp)^2)*dvmin3["govpart:hkcorp",2]^2 + 2*na.omit(hkcorp)*( vcovBK(dvmin2, diagonal=T,cluster="time")[1,"govpart:hkcorp"]) )),col="red")
lines(lowess(na.omit(hkcorp), dvmin2$coeff["govpart"] + na.omit(hkcorp)*dvmin2$coeff["govpart:hkcorp"] - 1.96*sqrt( dvmin3["govpart",2]^2 +(na.omit(hkcorp)^2)*dvmin3["govpart:hkcorp",2]^2 + 2*na.omit(hkcorp)*( vcovBK(dvmin2, diagonal=T,cluster="time")[1,"govpart:hkcorp"]) )),col="red")
## signif
abline(h=0,col="gray")
## high/low corporatism lines
abline(v=.15,col="blue",lwd=2)
abline(v=.9,col="blue",lwd=2)


## govpart--> minwag
plot(na.omit(hkcorp),dvmin4$coeff["govpart"] + na.omit(hkcorp)*dvmin4$coeff["govpart:hkcorp"],"l",lwd=3,ylab="Left Government",xlab="Level of Corporatism",main="Minimum Wage, Countries with Min Wage",ylim=c(-.002,.003))
## Rueda
lines(lowess(na.omit(hkcorp), dvmin4$coeff["govpart"] + na.omit(hkcorp)*dvmin4$coeff["govpart:hkcorp"] + 1.96*sqrt( dvmin5["govpart",2]^2 +(na.omit(hkcorp)^2)*dvmin5["govpart:hkcorp",2]^2 + 2*na.omit(hkcorp)*( vcovBK(dvmin4, diagonal=T,cluster="time")[1,"govpart:hkcorp"]) )),col="red")
lines(lowess(na.omit(hkcorp), dvmin4$coeff["govpart"] + na.omit(hkcorp)*dvmin4$coeff["govpart:hkcorp"] - 1.96*sqrt( dvmin5["govpart",2]^2 +(na.omit(hkcorp)^2)*dvmin5["govpart:hkcorp",2]^2 + 2*na.omit(hkcorp)*( vcovBK(dvmin4, diagonal=T,cluster="time")[1,"govpart:hkcorp"]) )),col="red")
## signif
abline(h=0,col="gray")
## high/low
abline(v=.15,col="blue",lwd=2)
abline(v=.9,col="blue",lwd=2)